import { configureStore } from '@reduxjs/toolkit'
import slice from './slice'

const store = configureStore({
  reducer: {
    zs: slice.reducer,
  },
})

// 监听redux中数据变化,然后将最新数据存储到本地缓存
store.subscribe(() => {
  localStorage.setItem('todos', JSON.stringify(store.getState().zs.todos))
})

export default store
